package edu.nf.supermarket.service.impl;

import edu.nf.supermarket.entity.Coupon;
import edu.nf.supermarket.mapper.CouponMapper;
import edu.nf.supermarket.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author yjj
 * @date 2025-05-21
 */
@Service("couponService")
public class CouponServiceImpl implements CouponService {
    @Autowired
    private CouponMapper couponMapper;
    @Override
    public List<Coupon> findCouponByUserId(Integer userId) {
        return couponMapper.findCouponByUserId(userId);
    }

    @Override
    public void updateCouponStatus(Integer couponId, Integer userId, Byte couponStatus) {
        couponMapper.updateCouponStatus(couponId,userId,couponStatus);
    }

    @Override
    public void addCoupon(Integer couponId, Integer userId, Byte couponStatus) {
        couponMapper.addCoupon(couponId,userId,couponStatus);
    }

    @Override
    public Coupon getNewUserCoupon() {
        return couponMapper.selectNewUserCoupon();
    }

    @Override
    public void addUserCoupon(Integer userId, Integer couponId, Byte couponStatus, LocalDateTime couponStartTime, LocalDateTime couponEndTime) {
        couponMapper.addUserCoupon(userId,couponId,couponStatus,couponStartTime,couponEndTime);
    }

    @Override
    public List<Coupon> findAllCoupons() {
        return couponMapper.selectAllCoupons();
    }
}
